package com.ruoyi.material.domain.vo;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 传输层
 */
@Data
@Accessors(chain = true)
public class FileRecordVo extends BaseEntity implements Comparable<FileRecordVo> {
    private static final long serialVersionUID = 1L;

    /** 主键 */
    private Long id;

    /** 文件名称 */
    @Excel(name = "文件名称")
    private String originalFileName;

    /** 文件类型 */
    @Excel(name = "文件类型")
    private String contentType;

    /** 文件大小 */
    @Excel(name = "文件大小")
    private Long fileSize;

    /** 文件路径 */
    @Excel(name = "文件路径")
    private String pathFileName;

    private String pCode;

    private String code;


    private String[] labels;
    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("originalFileName", getOriginalFileName())
                .append("contentType", getContentType())
                .append("fileSize", getFileSize())
                .append("pathFileName", getPathFileName())
                .append("pcode", getPCode())
                .append("code", getCode())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .toString();
    }

    @Override
    public int compareTo(FileRecordVo o) {
        int first = isFile(this.contentType),second =isFile(this.contentType);

        return    second - first;
    }

    public int isFile(String type){
        if (type.startsWith("f")){
            return 0;
        }else if (type.startsWith("i")){
            return  1;
        }else if (type.startsWith("v")){
            return  2;
        }else {
            return  3;
        }
    }
}
